/**
 * 成本跳转相关操作
 *
*/
export default {
  methods: {
    // 新窗口打开成本详情页
    toCostDetail(data) {
      const url = this.$router.resolve({
        name: 'costDetail',
        params: { id: data.id }
      });
      window.open(url.href, '_blank');
    },
    // 新窗口打开供应商详情页
    toSupplierDetail(data) {
      const supplierId = data.supplierId || data.supplier.id;
      const name = data.supplierFlag ? 'mengliSupplierDetail' : 'supplierManageDetail';
      const url = this.$router.resolve({
        name: name,
        params: { id: supplierId }
      });
      window.open(url.href, '_blank');
    },
    // 新窗口打开结算单详情页
    toSettleDetail(data) {
      if (data.settlementStatus === 1 || data.settlementStatus === 2) {
        const supplierId = data.supplierId || data.supplier.id;
        if (!supplierId) return;
        const url = this.$router.resolve({
          name: 'supplierDetail',
          query: {
            settleId: data.settleId,
            id: supplierId,
            isSettle: true
          }
        });
        window.open(url.href, '_blank');
      }
    }
  }
};
